package java8_6;

import java.util.Scanner;

public class Caishu {
    public static void main(String[] args) {
        int random = (int) (Math.random() * 20);
        Scanner sc = new Scanner(System.in);
        int num = 0;//定义  1
        do {
            System.out.println("请猜数字");
            num = sc.nextInt();//赋值   2
            //作比较
            if (num < random) {
                System.out.println("小了,重来");
            } else if (num > random) {
                System.out.println("大了,重来");
            } else if (num == random) {
                System.out.println("猜对了");
            }
        } while (num != random);//条件
    }
    }